<?php require_once VIEWPATH . 'common/header.php'; ?>
<body>
<div class="page-container">
    <form class="form form-horizontal">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>快递名称：</label>
            <div class="formControls col-xs-9 col-sm-9">
                <input type="text" class="input-text" value="<?=$name ?? '' ?>" placeholder="请输入快递名称" id="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>物流标识：</label>
            <div class="formControls col-xs-9 col-sm-9">
                <input type="text" class="input-text" value="<?=$express_marking ?? '' ?>" placeholder="请输入物流标识" id="express_marking">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>排序：</label>

            <div class="formControls col-xs-9 col-sm-9">
                <input type="text" class="input-text" value="<?=$sort_order ?? 0 ?>" placeholder="" id="sort_order" name="" style="width:25%">&nbsp;&nbsp;数字越大越靠前
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <span onClick="save();" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe632;</i> 保存
                </span>
                <span onClick="layer_close();" class="btn btn-default radius">&nbsp;&nbsp;取消&nbsp;&nbsp;</span>
            </div>
        </div>
        <input type="hidden" id="express_id" value="<?=$express_id??''?>">
    </form>
</div>
<?php require_once VIEWPATH . 'common/footer.php'; ?>
</body>
</html>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">

    mustNum($("#sort_order"));

    function mustNum($object){
        $object.bind({
                keyup:function(){
                     var txt = $object.val();
                     var reg = /^[\d]+$/;
                     if(!reg.test(txt) ){
                            $(this).val('');
                     }
                },
                focus:function(){
                    if ($(this).val() == 0){
                        $(this).val('');
                    }
                },
                blur:function(){
                    if ($(this).val() == ''){
                        $(this).val('');
                    }
                }
        }); 
    }
    
    function save() {
        var express_id = $("#express_id").val();
        var name = $("#name").val();
        var sort_order = $("#sort_order").val();
        var express_marking = $("#express_marking").val();
        var params = {
            name:name,
            sort_order: sort_order,
            express_marking:express_marking
        };
        if(express_id){
            params.express_id = express_id;
        }
        $.post("/express/update", params, function (data) {
            if (data.code != 1) {
                layer.msg(data.message);
            }
            layer.msg(data.message);
            parent.location.reload();
        },'json');
    }



</script>

